<%--
  Created by IntelliJ IDEA.
  User: gaoran
  Date: 2020/3/24
  Time: 17:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="../../css/email/m/jquery.mobile.css"/>
<link rel="stylesheet" href="../../lib/mui/mui/mui.min.css"/>

<link rel="stylesheet" href="../../css/email/m/styles.css"/>
<link rel="stylesheet" href="../../css/email/m/style.css">
<link rel="stylesheet" href="../../css/email/m/mail.css">
<script type="text/javascript" src="../../js/jquery/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="../../js/base/base.js"></script>
<script type="text/javascript" src="../../js/ewx/waterMark.js?20190819.2"></script>
<script type="text/javascript" src="../../lib/mui/mui/mui.min.js"></script>
<script type="text/javascript" src="../../js/diary/m/simbaJs.js"></script>


<link rel="stylesheet" href="../../lib/mui/mui/mui.picker.min.css"/>
<script type="text/javascript" src="../../lib/mui/mui/mui.picker.min.js"></script>
<style >
    .banner {
        margin: 0;
    }
    .banner img {
        width: 100%;
    }
    .msg{
        margin: 2%;
        text-align: center;
    }

    .attend_msg{
        border-top: #BDBDBD solid 1px;
    }
    .attend_ul li{
        float: left;
        width: 46%;
        margin: 2%;
        background: #0479b2;
        color: #ffffff;
        height: 60px;
        border-radius: 5px;
        line-height: 60px;
        position: relative;
    }

    .attend_ul li img {
        width: 25px;
        position: absolute;
        top: 16px;
        left: 4px;
    }

    .attend_ul li span {
        font-size: 16px;
        margin-left: 30px;
    }

    .addAttendCant {
        opacity: 0.5;
    }
</style>
<head>
    <title>考勤签到</title>
</head>
<body>
    <div class="banner" >
        <img src="/img/ewx/attend/banner.png">
    </div>

    <div class="msg">
        <div style="font-weight: bold;font-size: 30px;">
            <span class="date">2020年3月24日</span><span class="week" style="margin-left: 5px;"></span>
        </div>
        <div style="color: #BDBDBD;margin-top: 2%;">
            考勤类型：<span class="attend_type">默认考勤类型</span>
        </div>
    </div>
    <div class="attend_msg">
        <div style="margin: 2%;">
            <ul class="attend_ul">

            </ul>
        </div>
    </div>

<script>

    $(function(){
        var nowDate = new Date();
        // 设置星期
        var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
        var myddy=nowDate.getDay();
        $('.week').html(weekday[myddy]);
        // 设置时间
        $('.date').html(nowDate.getFullYear()+"年"+(nowDate.getMonth()+1)+"月"+nowDate.getDate()+"日");


        $.ajax('/attendSet/selsectAttendSet',{
            dataType:'json',//服务器返回json格式数据
            type:'get',//HTTP请求类型
            success:function(data){
                if(data.flag){
                    var obj;
                    if(data.obj.length>0){
                        obj = data.obj[0];
                    } else {
                        obj = data.data[0];
                    }

                    var li_str = '';
                    for (let i = 1; i <= 6; i++) {
                        var atimeSet = obj["atime"+i+"Set"];
                        var atime = obj["atime"+i];
                        if(atimeSet!=undefined&&atimeSet!=''&&atime!=undefined){
                            var setArr = atimeSet.split("|");
                            if(setArr[0]=='1'){
                                var classes = "addAttend";
                                // 考勤签到限制 暂时注释
                                /*if(ifTimeOut(atime)){
                                    classes = "addAttendCant"
                                }*/
                                if(setArr[1]=='1'){
                                    li_str+='<li class="'+classes+'" type="'+i+'" style="background: #fa6165">' +
                                        '<img src="/img/ewx/attend/shangban.png">' +
                                        '<span class="shangban" atime="'+atime+'">上班（'+atime+'）</span>' +
                                        '</li>';
                                } else if(setArr[1]=='2'){
                                    li_str+='<li class="'+classes+'" type="'+i+'"  style="background: #2798f5">' +
                                        '<img src="/img/ewx/attend/xiaban.png">' +
                                        '<span class="xiaban" atime="'+atime+'">下班（'+atime+'）</span>' +
                                        '</li>';
                                }
                            }
                        }
                    }


                    if(obj.isOvertime=='1'){
                        li_str+='<li class="addAttend" type="7" style="background: #61c4c4">' +
                                '<img src="/img/ewx/attend/shangban.png">' +
                                '<span  >加班上班</span>' +
                            '</li>'+
                            '<li class="addAttend" type="8" style="background: #61c4c4">' +
                                '<img src="/img/ewx/attend/xiaban.png">' +
                                '<span>加班下班</span>' +
                            '</li>'
                    }
                    if(obj.isDuty=='1'){
                        li_str+='<li class="addAttend" type="9"  style="background: #61c4c4">' +
                                '<img src="/img/ewx/attend/shangban.png">' +
                                '<span >值班上班</span>' +
                            '</li>'+
                            '<li class="addAttend" type="10"  style="background: #61c4c4">' +
                                '<img src="/img/ewx/attend/xiaban.png">' +
                                '<span >值班下班</span>' +
                            '</li>'
                    }
                    if(obj.isGo=='1'){
                        li_str+='<li class="flow_li" style="background: #61c4c4">' +
                            '<img src="/img/ewx/attend/waichu.png">' +
                            '<span class="waichu" >外出申请</span>' +
                            '</li>';
                    }
                    if(obj.isLeave=='1'){
                        li_str+='<li class="flow_li" style="background: #61c4c4">' +
                            '<img src="/img/ewx/attend/waichu.png">' +
                            '<span class="qingjia" >请假申请</span>' +
                            '</li>';
                    }
                    if(obj.isTrip=='1'){
                        li_str+='<li class="flow_li" style="background: #61c4c4">' +
                            '<img src="/img/ewx/attend/waichu.png">' +
                            '<span class="chuchai" >出差申请</span>' +
                            '</li>';
                    }
                    if(obj.isOut=='1'){
                        li_str+='<li style="background: #61c4c4">' +
                            '<img src="/img/ewx/attend/waichu.png">' +
                            '<span class="waiqin">外勤签到</span>' +
                            '</li>';
                    }

                    $('.attend_ul').append(li_str);

                    // 点击申请跳转
                    $('.flow_li').bind('click',function(){
                        window.open('/workflow/work/workflowIndexh5')
                    })

                    $('.addAttend').bind('click',function(){
                        window.open('/ewx/attendAdd?type='+$(this).attr("type"))
                    })
                }
            }
        })


        // 判断是否超时 签到前后一小时可以签到 如果超过允许签到时间返回true
        // time是 时分秒 如 09:00:00
        function ifTimeOut(time) {
            var times = time.split(":");
            var attendDate = new Date();
            attendDate.setHours(times[0]);
            attendDate.setMinutes(times[1]);
            attendDate.setSeconds(times[2]);
            let attendTimeStemp = attendDate.getTime()/1000;
            let nowTimeStemp = nowDate.getTime()/1000;
            if(nowTimeStemp<attendTimeStemp-60*60||nowTimeStemp>attendTimeStemp+60*60){
                return true;
            }
            return false;
        }


    })

</script>
</body>
</html>
